<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAssetKeysTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('asset_keys', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->bigInteger('asset_id')->index()->comment('用户资产ID');
            $table->string('key', 16)->comment('兑换码');
            $table->string('prev_code', 16)->nullable()->comment('转售商品的原兑换码');
            $table->dateTime('use_time')->nullable()->comment('使用时间');
            $table->bigInteger('partner_id')->default(0)->comment('使用兑换码的合作方ID');
            $table->string('status', 16)->default(\App\Enums\AssetKeyStatus::NOT_USE)->comment('兑换码状态');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('asset_keys');
    }
}
